/*
 * Copyright (c) 2023, 2024,yzc.cn All rights reserved.
 *
 */
package cn.yzc.singleton_pattern;

/**
 * <p>Project: springbootDemo - HungrySingleton</p>
 * <p>Powered by yzc On 2024-03-19 16:24:52</p>
 * <p>描述：<p>
 *
 * @author yzc [youzhicheng0415@163.com]
 * @version 1.0
 * @since 17
 */
//单例模式  饿汉模式
//类被创建时创建
public class HungrySingleton {

    //创建单例对象
    private static final HungrySingleton instance = new HungrySingleton();

    //定义私有的构造函数，就不会被实例化
    private HungrySingleton() {
    }
    //获取对象
    public static HungrySingleton getInstance(){
        System.out.println("你好，饿汉模式");
        return instance;
    }
}
